package com.wanxi.test;

import java.util.Random;
import java.util.Scanner;

public class GuessMethod {
    public static void main(String[] args) {
        /**
         * 1.得到随机数
         * 2.得到输入的数
         * 3.判断结果
         */
        int randomNum = getRandomNum(1, 100);
        int num = getNumSystemIn("请输入一个整数");
        judge(randomNum, num);
    }

    private static void judge(int randomNum, int num) {
        if (randomNum > num) {
            System.out.println("你猜小了");
        } else if (randomNum < num) {
            System.out.println("你猜大了");
        } else {
            System.out.println("你猜中了");
        }
    }

    private static int getNumSystemIn(String str) {
        Scanner scanner = new Scanner(System.in);
        System.out.println(str);
        return scanner.nextInt();
    }

    /**
     * 根据最小和最大得到之间的随机数
     *
     * @param start
     * @param end
     * @return
     */
    private static int getRandomNum(int start, int end) {
        Random random = new Random();
        return random.nextInt(100) + 1;
    }
}
